#include "instruct.h"
#include "register.h"
#include "def.h"
#include <stdio.h>

int popIsRun(char opt){
    if(opt==POP){
        return 2;
    }
    return 0;
}
int popParseRun(Register*R){
    char*code=R->code;
    int pc=R->RPC;
    char opt=code[pc];
    if(opt==POP){
        char r1=code[pc+1];
        int d=R->RSS+R->RSP-4;
        u32 num=byte2int(code[d+3],code[d+2],code[d+1],code[d+0]);
        if(r1==AX){
            R->RAX=num;
        }else if(r1==BX){
            R->RBX=num;
        }else if(r1==CX){
            R->RCX=num;
        }else if(r1==DX){
            R->RDX=num;
        }else if(r1==EX){
            R->REX=num;
        }else if(r1==BP){
            R->RBP=num;
        }else if(r1==SS){
            R->RSS=num;
        }else if(r1==SP){
            R->RSP=num;
        }
    }
	R->RSP=R->RSP-4;
    R->RPC+=popIsRun(opt);
    return 0;
}